package com.cmc6.common.model.entity;

import com.cmc6.common.config.BaseConfig;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Data
@Document(indexName = "cmc6-admin-error")
public class EsErrorDO {

    @Id
    @ApiModelProperty(value = "es 主键 id")
    private String _id;

    @ApiModelProperty(value = "uuid")
    private String errorId;

    @ApiModelProperty(value = "请求的 uri")
    private String uri;

    @ApiModelProperty(value = "请求人 id")
    private Long createId;

    @Field(type = FieldType.Date)
    @ApiModelProperty(value = "请求的时间")
    private Date createTime = new Date();

    @ApiModelProperty(value = "请求的服务名")
    private String service = BaseConfig.applicationName;

    /**
     * {@link com.cmc6.common.model.enums.RequestCategoryEnum}
     */
    @ApiModelProperty(value = "请求的类别：1 H5（网页端） 2 APP（移动端） 3 PC（桌面程序） 4 微信小程序")
    private Byte category;

    @ApiModelProperty(value = "请求者 ip")
    private String ip;

    @ApiModelProperty(value = "IpUtil.getRegion() 获取到的 ip所处区域")
    private String region;

    @ApiModelProperty(value = "请求主机的地址")
    private String address = BaseConfig.address;

    @ApiModelProperty(value = "请求主机的端口")
    private Integer port = BaseConfig.port;

    @ApiModelProperty(value = "错误信息")
    private String errorMsg;

    @ApiModelProperty(value = "是否已读")
    private boolean readFlag;

}
